package Thread2;

/**
 * @Author wangzhipeng
 * @Date 2020-08-21 11:39 上午
 * @Description
 */
public class DoBusiness {
    private int number;
    private int currentNum = 0;


    public DoBusiness(int number) {
        this.number = number;
    }

    /**
     * 等待
     * @param
     */
    public synchronized void checkNumber(){
        while (currentNum != this.number){
            System.out.println("不到我，等一会");
            try {
                wait();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
        System.out.println("到我办业务了，业务中》》》》");
    }

    public synchronized void call(int num){
        System.out.println("请"+num+"到柜台办理业务");
        currentNum = num;
        notifyAll(); //通知所有等待的人
    }

}
